/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: #f5f5f5;
    color: #333;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 20px;
}

section {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

section:hover { transform: translateY(-2px); }

h2 {
    font-size: 20px;
    margin: 0 0 15px;
    color: #444;
}

textarea, input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px;
    font-family: monospace;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

textarea:focus, input:focus {
    border-color: #007bff;
    outline: none;
}

.checkbox-group { margin-top: 10px; }
label { font-size: 14px; color: #666; }
input[type="checkbox"] { margin-right: 5px; }

select {
    padding: 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 100%;
}

.template-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.template-row select#templateCategory { flex: 1; min-width: 150px; }
.template-row select#templateSelect { flex: 2; min-width: 200px; }

.template-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.3s;
}

button:hover { background: #0056b3; }
#deleteTemplate { background: #dc3545; }
#deleteTemplate:hover { background: #b02a37; }

#result {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
}

.export-buttons { display: flex; gap: 15px; margin-top: 15px; }
.export-status { margin-top: 10px; font-size: 14px; color: #666; }

.error { color: #dc3545; font-weight: bold; }

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: monospace;
    table-layout: fixed; /* 固定表格布局 */
}

th, td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
    word-wrap: break-word; /* 强制换行 */
    overflow-wrap: break-word; /* 兼容性 */
}

th:first-child, td:first-child {
    width: 10%; /* 序号列固定宽度 */
}

th { background: #f2f2f2; font-weight: bold; }
tr:nth-child(even) { background: #f9f9f9; }
tr:hover { background: #f5f5f5; }

/* 单元格内容样式 */
.cell-content {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

/* 确保表格在暗色主题下也有合适的样式 */
[data-theme="dark"] table {
    border-color: var(--border-color);
}

[data-theme="dark"] th {
    background-color: var(--header-bg);
    color: var(--text-color);
}

[data-theme="dark"] td {
    border-color: var(--border-color);
    color: var(--text-color);
}

/* 页脚 */
.footer {
    text-align: center;
    font-size: 14px;
    color: #888;
    margin-top: 30px;
    padding: 15px 0;
}

.footer a { color: #007bff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* 模态框（居中显示） */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.modal-buttons { display: flex; gap: 10px; margin-top: 15px; justify-content: flex-end; }

/* 加载指示器 */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    align-items: center;
    gap: 10px;
}

/* 主题切换 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    padding: 8px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.dark-mode {
    background: #1e1e1e;
    color: #ddd;
}

body.dark-mode section, body.dark-mode .modal-content { background: #2a2a2a; }
body.dark-mode #result, body.dark-mode textarea, body.dark-mode input, body.dark-mode select { background: #333; border-color: #444; color: #ddd; }
body.dark-mode th { background: #3a3a3a; }
body.dark-mode tr:nth-child(even) { background: #2e2e2e; }
body.dark-mode tr:hover { background: #383838; }
body.dark-mode .theme-toggle { background: #444; }

/* 响应式设计 */
@media (max-width: 768px) {
    .container { padding: 10px; }
    .template-row, .template-controls, .export-buttons { flex-direction: column; }
    .template-row select { width: 100%; }
    button { width: 100%; }
    th, td { width: auto; } /* 移动端自适应 */
} 